package com.pda.xinma.adapter;

import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.widget.EditText;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.pda.xinma.R;
import com.pda.xinma.bean.InStoregeListBean;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;

import java.util.List;

public class InStoregeAdapter extends BaseAdapter<InStoregeListBean> {
    public InStoregeAdapter(int layoutResId, @Nullable List<InStoregeListBean> data) {
        super(layoutResId, data);
        addChildClickViewIds(R.id.tv_manzSpecId);
        addChildClickViewIds(R.id.tv_delete);
    }

    @Override
    protected void convert(BaseViewHolder helper, InStoregeListBean item) {
        super.convert(helper, item);
        helper.setText(R.id.tv_orderNo,item.getProOrderNo());
        helper.setText(R.id.tv_articleId,item.getArticleId());
        helper.setText(R.id.tv_model,item.getModel());
        helper.setText(R.id.tv_grade,item.getGrade());
        helper.setText(R.id.tv_manzSpecId,item.getManzSpecName());
        EditText etNum=helper.getView(R.id.et_num);
        etNum.setText(item.getInNum());
        etNum.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (!TextUtils.isEmpty(etNum.getText().toString())){
                    item.setInNum(etNum.getText().toString());
                }

            }
        });
    }
}
